//
//  DetailHousePageVc.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/20.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "DetailHousePageVc.h"
#import "DetailHouseTypeSubVc.h"
#import "config.h"
#import "NSString+category.h"
@interface DetailHousePageVc ()<ViewPagerDataSource,ViewPagerDelegate,DetailHouseTypeSubVcDelegate>

@property (nonatomic,strong)UILabel *lable1,*lable2,*lable3;

@end

@implementation DetailHousePageVc
@synthesize lable1,lable2,lable3;

- (void)viewDidLoad {
    self.delegate = self;
    self.dataSource = self;
    [super viewDidLoad];

}

#pragma mark - ViewPagerDataSource
- (NSUInteger)numberOfTabsForViewPager:(ViewPagerController *)viewPager {
    return 3;
}


- (UIView *)viewPager:(ViewPagerController *)viewPager viewForTabAtIndex:(NSUInteger)index {
    
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ([UIScreen mainScreen ].applicationFrame.size.width)/3, 36)];

    [lable setFont:[UIFont systemFontOfSize:13]];
    lable.backgroundColor = [UIColor clearColor];
    lable.font = [UIFont systemFontOfSize:15.0];
    lable.textAlignment = NSTextAlignmentCenter;
    lable.textColor =  [UIColor redColor];
    
    
    if (index==0) {
        
        lable1=lable;
//        [lable1 setAttributedText:[NSString makeLineStyle:@"全部" color:UIColorFromRGB(0x333333) fontSize:14]];
        lable1.text = @"全部";
        return lable1;
        
    }else if(index==1){
        
        lable2=lable;
//         [lable2 setAttributedText:[NSString makeLineStyle:@"现房" color:UIColorFromRGB(0x333333) fontSize:14]];
        lable2.text = @"现房";
        return lable2;
        
    }else if (index==2){
        
        lable3=lable;
//        [lable3 setAttributedText:[NSString makeLineStyle:@"期房" color:UIColorFromRGB(0x333333) fontSize:14]];
        lable3.text = @"期房";
        return lable3;
    }
    
    return lable;
}


- (UIViewController *)viewPager:(ViewPagerController *)viewPager contentViewControllerForTabAtIndex:(NSUInteger)index {
    DetailHouseTypeSubVc *cvc = [[DetailHouseTypeSubVc alloc]init];
    
    
    if (index==1) {
        cvc.ForwardDelivery = @"0";
        cvc.countLab = lable2;
    }else if (index==2){
        cvc.ForwardDelivery = @"1";
        cvc.countLab = lable3;
    }else{//  0
        cvc.ForwardDelivery = @"3";
        cvc.countLab = lable1;
    }
    cvc.premisesId = self.premisesId;
    cvc.delegate = self;
    cvc.lab1 = self.lab1;
    cvc.lab2 = self.lab2;
    return cvc;
}

-(void)DetailHouseTypeSubVcClickBtn:(NSInteger)houseId
{
    if (self.delegate2 && [self.delegate2 respondsToSelector:@selector(DetailHousePageVcClickBtn:)])
    {
        [self.delegate2 DetailHousePageVcClickBtn:houseId];
    }
}
#pragma mark - ViewPagerDelegate
- (UIColor *)viewPager:(ViewPagerController *)viewPager colorForComponent:(ViewPagerComponent)component withDefault:(UIColor *)color {
    
    switch (component) {
        case ViewPagerIndicator:
            
            return [UIColor redColor];
            break;
            
        case ViewPagerTabsView:
            
            return  UIColorFromRGB(0xf3f3f3);
            break;
            
        default:
            break;
    }
    
    return color;
}


-(CGFloat)viewPager:(ViewPagerController *)viewPager valueForOption:(ViewPagerOption)option withDefault:(CGFloat)value{
    
    if (option==ViewPagerOptionTabWidth) {
        return ([UIScreen mainScreen ].applicationFrame.size.width)/3 ;
    }else if(option==ViewPagerOptionTabHeight){
        return 36;
    }
    return value;
}


- (void)viewPager:(ViewPagerController *)viewPager didChangeTabToIndex:(NSUInteger)index{
    
    if (index==0) {
        [lable1 setTextColor:[UIColor redColor]];
        [lable2 setTextColor:UIColorFromRGB(0x333333)];
        [lable3 setTextColor:UIColorFromRGB(0x333333)];
//        [lable1 setAttributedText:[NSString makeLineStyle:lable1.text color:[UIColor redColor] fontSize:14]];
//        [lable2 setAttributedText:[NSString makeLineStyle:lable2.text color:UIColorFromRGB(0x333333) fontSize:14]];
//        [lable3 setAttributedText:[NSString makeLineStyle:lable3.text color:UIColorFromRGB(0x333333) fontSize:14]];
    }else if (index==1){
        
        [lable1 setTextColor:UIColorFromRGB(0x333333)];
        [lable2 setTextColor:[UIColor redColor]];
        [lable3 setTextColor:UIColorFromRGB(0x333333)];
//        [lable2 setAttributedText:[NSString makeLineStyle:lable2.text color:[UIColor redColor] fontSize:14]];
//        [lable1 setAttributedText:[NSString makeLineStyle:lable1.text color:UIColorFromRGB(0x333333) fontSize:14]];
//        [lable3 setAttributedText:[NSString makeLineStyle:lable3.text color:UIColorFromRGB(0x333333) fontSize:14]];
    }else{
        
        [lable1 setTextColor:UIColorFromRGB(0x333333)];
        [lable2 setTextColor:UIColorFromRGB(0x333333)];
        [lable3 setTextColor:[UIColor redColor]];
//        [lable3 setAttributedText:[NSString makeLineStyle:lable3.text color:[UIColor redColor] fontSize:14]];
//        [lable1 setAttributedText:[NSString makeLineStyle:lable1.text color:UIColorFromRGB(0x333333) fontSize:14]];
//        [lable2 setAttributedText:[NSString makeLineStyle:lable2.text color:UIColorFromRGB(0x333333) fontSize:14]];
    }
}


@end
